package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(basename2("a/b/c.go"))
	fmt.Println(basename2("c.d.go"))
	fmt.Println(basename2("abc"))
}

func basename2(s string) string {
	index4Slash := strings.LastIndex(s, "/")
	s = s[index4Slash+1:]
	if index4Dot := strings.LastIndex(s, "."); index4Dot >= 0 {
		s = s[:index4Dot]
	}
	return s
}
